<?php
    // Is an admin connected ?
    if (isset($_SESSION['id']) && isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] === true)
    {
        // Including the database connexion.
        require_once 'src/dbconnect.php';
        require_once 'src/backoffice/model/model_main.php';
        
        // Including the header
        require_once 'src/backoffice/view/view_header.php';
        if (isset($_GET['a']))
        {
            $action = $_GET['a'];
            switch($action)
            {
                case 'showtable':
                    require_once 'src/backoffice/controller/controller_table.php';
                    break;
//                case 'deleterow':
//                    require_once 'src/backoffice/controller/controller_table.php';
//                    break;
            }
        }
        else
        {
            $dbTablesNames = getDbTablesNames($db);
            require_once 'src/backoffice/view/view_main.php';
        }
    }
    else
    {
        require_once 'src/class_error.php';
        $errorMessage = new Error('Vous ne disposez pas des droits nécéssaires à l\'affichage du contenu de cette partie du site.', 1);
        $errorMessage->show();
    }
?>
